package com.sgb.kjwl.view.ui.activity.enterprise;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.widget.NestedScrollView;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.google.gson.Gson;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityMakeOverDetailBinding;
import com.sgb.kjwl.di.enterprise.DaggerEnterpriseComponent;
import com.sgb.kjwl.di.enterprise.EnterpriseModule;
import com.sgb.kjwl.model.entity.enterprise.CompanyDetailEntity;
import com.sgb.kjwl.model.entity.enterprise.CopyrightEntity;
import com.sgb.kjwl.model.entity.enterprise.PatentDetailEntity;
import com.sgb.kjwl.model.entity.enterprise.PropertyDetailEntity;
import com.sgb.kjwl.model.entity.enterprise.RegisterCompanyArea;
import com.sgb.kjwl.model.entity.enterprise.TrademarkEntity;
import com.sgb.kjwl.utils.ActivityClassHelper;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.utils.DialogHelper;
import com.sgb.kjwl.utils.DisplayUtil;
import com.sgb.kjwl.utils.PointUtils;
import com.sgb.kjwl.utils.TextSizeUtils;
import com.swgk.core.util.UiUtil;
import com.swgk.core.util.UserOperating;
import com.sgb.kjwl.view.event.CustomViewsInfo;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.event.MemberEvent;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.CertificationActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.TextViewBindingAdapter;
import com.sgb.kjwl.view.ui.fragment.enterprise.MakeOverDetailQuestionFragment;
import com.sgb.kjwl.view.ui.fragment.enterprise.RecommendForYouFragment;
import com.sgb.kjwl.viewmodel.enterprise.MakeOverDetailModel;
import com.stx.xhb.androidx.XBanner;
import com.swgk.core.base.aroute.AppRouteConstant;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.util.ClickUtils;
import com.swgk.core.util.DateUtils;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

@Route(path = AppRouteConstant.ZiChan.ZICHAN_MAKEOVERDETAILACTIVITY)
public class MakeOverDetailActivity extends AppActivity {

    private ActivityMakeOverDetailBinding binding;
    private String telPhone;
    private String mTag;
    private String mId;
    private String man;
    private String companyNo;
    private String childPosition;
    RequestOptions options;
    RequestOptions personOptions;
    RequestOptions teamOptions;
    private long ids;
    private String detailType = "";
    private String categoryPatent = "";
    private int statusGZ = 0;//0未关注
    private String businessId = "";
    private String businessName = "";
    private String dealCompanyName = "";
    private String dealCompanyNo = "";
    private String dealTeamName = "";
    private String dealTeamNo = "";
    private String dealUserName = "";
    private String dealUserNo = "";
    private boolean isTeam = false;//当前是团队
    private String currentNo = "";
    private String dataId = "";
    private String currentPhone = "";
    private String category = "";
    private final String[] titleName = new String[]{"产品", "详情", "推荐"};
    private boolean isTabClick;
    @Autowired(name = "detaildata")
    public String detaildata;
    @Autowired(name = "no")
    public String no;
    @Inject
    MakeOverDetailModel makeOverDetailModel;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerEnterpriseComponent.builder().appComponent(appComponent)
                .enterpriseModule(new EnterpriseModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected boolean statusBarDark() {
        return true;
    }

    @Override
    protected void initView() {
        super.initView();
        binding = DataBindingUtil.setContentView(this, R.layout.activity_make_over_detail);
        if (!TextUtils.isEmpty(detaildata)){
            detailType = detaildata;
            if (!TextUtils.isEmpty(no)){
                ids=Long.valueOf(no);
            }else {
                ids = 0;
            }

        }else {
            detailType = getIntent().getStringExtra("detail");
            ids = getIntent().getLongExtra("id", 0);
        }

        binding.setDetail(ActivityClassHelper.getDetail(detailType));

        options = new RequestOptions().placeholder(R.mipmap.gongsiqiye)//图片加载出来前，显示的图片
                .fallback(R.mipmap.gongsiqiye) //url为空的时候,显示的图片
                .error(R.mipmap.gongsiqiye);//图片加载失败后，显示的图片

        personOptions = new RequestOptions().placeholder(R.mipmap.morentu_person)//图片加载出来前，显示的图片
                .fallback(R.mipmap.morentu_person) //url为空的时候,显示的图片
                .error(R.mipmap.morentu_person);//图片加载失败后，显示的图片

        teamOptions = new RequestOptions().placeholder(R.mipmap.morentu_tuandui)//图片加载出来前，显示的图片
                .fallback(R.mipmap.morentu_tuandui) //url为空的时候,显示的图片
                .error(R.mipmap.morentu_tuandui);//图片加载失败后，显示的图片

        binding.bottomView.setOnClickListener(this);
        binding.llReport.setOnClickListener(this);
        binding.llHanxun.setOnClickListener(this);
        binding.llFocus.setOnClickListener(this);
        binding.tvGotobug.setOnClickListener(this);
        binding.tvTalkprice.setOnClickListener(this);
        binding.backViewToolBar.setOnClickListener(this);
        binding.backViewToolBarV.setOnClickListener(this);
        binding.llMakeOverDetailCompanyDetail.setOnClickListener(this);

        binding.tabGroup.addTab(binding.tabGroup.newTab().setText(titleName[0]));
        binding.tabGroup.addTab(binding.tabGroup.newTab().setText(titleName[1]));
        binding.tabGroup.addTab(binding.tabGroup.newTab().setText(titleName[2]));

        //设置每个table的点击事件和tag
        binding.tabGroup.getTabAt(0).view.setTag(0);
        binding.tabGroup.getTabAt(0).view.setOnClickListener(mTabOnClickListener);
        binding.tabGroup.getTabAt(1).view.setTag(1);
        binding.tabGroup.getTabAt(1).view.setOnClickListener(mTabOnClickListener);
        binding.tabGroup.getTabAt(2).view.setTag(2);
        binding.tabGroup.getTabAt(2).view.setOnClickListener(mTabOnClickListener);
        binding.displayView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
            if (scrollY == 0) {// 滚动到顶
                binding.tabGroup.selectTab(binding.tabGroup.getTabAt(0));
            } else if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {// 滚动到底
                binding.tabGroup.selectTab(binding.tabGroup.getTabAt(2));
            } else if (scrollY > 250 && scrollY < 3000) {
                binding.tabGroup.selectTab(binding.tabGroup.getTabAt(1));
            }
        });
        setToolBar();
    }

    private View.OnClickListener mTabOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //重写tabLayout点击事件
            int tagY;
            int position = (int) v.getTag();
            TabLayout.Tab tab = binding.tabGroup.getTabAt(position);
            if (tab != null) {
                tab.select();
            }
            if (position == 0 && binding.tabGroup.getTabAt(position).isSelected() == true) {
                binding.displayView.scrollTo(0, 0);
                moveToTop();
                binding.appBarLayout.setExpanded(true, true);
            } else if (position == 1 && binding.tabGroup.getTabAt(position).isSelected() == true) {
                tagY = binding.llDetail.getTop();
                binding.displayView.scrollTo(0, tagY + 5);
                binding.toolbar.setBackgroundColor(getResources().getColor(R.color.white));
                binding.toolbar.setAlpha(1);
                binding.appBarLayout.setExpanded(false,false);
            } else if (position == 2 && binding.tabGroup.getTabAt(position).isSelected() == true) {
                tagY = binding.flRecommendList.getTop();
                binding.displayView.scrollTo(0, tagY + 5);
                binding.toolbar.setBackgroundColor(getResources().getColor(R.color.white));
                binding.toolbar.setAlpha(1);
                binding.appBarLayout.setExpanded(false,false);
            }
        }
    };

    /**
     * 初始化setToolBar
     */
    private void setToolBar() {
        binding.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
            binding.toolbar.setBackgroundColor(changeAlpha(getResources().getColor(R.color.white), Math.abs(verticalOffset * 1.0f) / appBarLayout.getTotalScrollRange()));
            binding.toolbar.setAlpha(Math.abs(verticalOffset * 1.0f) / appBarLayout.getTotalScrollRange());
        });
    }

    /**
     * 根据百分比改变颜色透明度
     */
    public int changeAlpha(int color, float fraction) {
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        int alpha = (int) (Color.alpha(color) * fraction);
        return Color.argb(alpha, red, green, blue);
    }

    private void moveToTop() {
        CoordinatorLayout.Behavior behavior =
                ((CoordinatorLayout.LayoutParams) binding.appBarLayout.getLayoutParams()).getBehavior();
        if (behavior instanceof AppBarLayout.Behavior) {
            AppBarLayout.Behavior appBarLayoutBehavior = (AppBarLayout.Behavior) behavior;
            int topAndBottomOffset = appBarLayoutBehavior.getTopAndBottomOffset();
            if (topAndBottomOffset != 0) {
                appBarLayoutBehavior.setTopAndBottomOffset(0);
            }
        }
    }

    @Override
    protected void init() {
        getDetail();
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(MemberEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_REPORT_INQUIRE_FINISH) {
            getDetail();
        }
    }


    public void getDetail() {
        switch (detailType) {
            case "商标":
                makeOverDetailModel.trademarkDetail(ids);
                makeOverDetailModel.getAttentionStatus(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""), 5, String.valueOf(ids));
                break;
            case "版权":
                makeOverDetailModel.copyrightDetail(ids);
                makeOverDetailModel.getAttentionStatus(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""), 4, String.valueOf(ids));
                break;
            case "专利":
                makeOverDetailModel.patentDetail(ids);
                makeOverDetailModel.getAttentionStatus(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""), 3, String.valueOf(ids));
                break;
            case "公司":
                binding.rlTop.setVisibility(View.GONE);
                makeOverDetailModel.companyDetail(ids);
                makeOverDetailModel.getAttentionStatus(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""), 6, String.valueOf(ids));
                break;
            case "资产":
                makeOverDetailModel.propertyDetail(ids);
                makeOverDetailModel.getAttentionStatus(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""), 1, String.valueOf(ids));
                break;
        }
    }

    @Override
    public void onMultiClick(View v) {
        super.onMultiClick(v);
        switch (v.getId()) {
            case R.id.bottom_view:
                if (!ClickUtils.isDoubleClick()) {
                    if (!UserOperating.getInstance().isLogged()) {
                        VerificationCodeLoginActivity.start(MakeOverDetailActivity.this);
                    } else {
                        DialogHelper.showDialog(this, "确认呼叫", man + ":" + telPhone, "确定", new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {
                                ActivityJump.jumpToPhone(MakeOverDetailActivity.this, telPhone);
                            }
                        });
                    }
                }
                break;
            case R.id.ll_make_over_detail_company_detail:
                if (!ClickUtils.isDoubleClick()) {
                    if ("企业".equals(mId)) {
                        WebsiteInfoActivity.start(this, mTag, 1);
                    } else if ("团队".equals(mId)) {
//                            ActivityJump.jumpToActivity(this, ProfessionalTeamDetailActivity.class, Pair.create("id", Long.parseLong(mTag)));
                        WebsiteInfoActivity.start(this, mTag, 2);
                    } else if ("个人".equals(mId)) {
                        WebsiteInfoActivity.start(this, mTag, 0);
                    }
                }
                break;
            case R.id.tv_attention_goods:
                break;
            case R.id.ll_report://举报
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(MakeOverDetailActivity.this);
                } else {
                    if (UserOperating.getInstance().isTeam() || isTeam) {
                        DialogHelper.showSingleDialog(this, "温馨提示", "该功能正在开发中，敬请期待~", "确定", true, new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {

                            }
                        });
                    } else {
                        ReportEnterpriseActivity.start(this, businessId, businessName, "1", detailType.equals("商标") ? "2" : detailType.equals("版权") ? "4" :
                                        detailType.equals("专利") ? "3" : detailType.equals("公司") ? "5" : detailType.equals("资产") ? "6" : "", dealCompanyName, dealCompanyNo,
                                dealTeamName, dealTeamNo, dealUserName, dealUserNo);
                    }
                }
                break;
            case R.id.ll_focus://关注
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(MakeOverDetailActivity.this);
                } else {
                    if (SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LOGIN_PHONE, "").equals(currentPhone)) {
                        MToast.showToast(this, "不能关注当前账号下发布的内容！");
                        return;
                    }
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", ids);
                    map.put("dataId", dataId);
                    switch (detailType) {
                        case "商标":
                            map.put("type", 5);
                            break;
                        case "版权":
                            map.put("type", 4);
                            break;
                        case "专利":
                            map.put("type", 3);
                            break;
                        case "公司":
                            map.put("type", 6);
                            break;
                        case "资产":
                            map.put("type", 1);
                            break;
                    }
                    map.put("attentionNot", statusGZ);
                    map.put("attentionTime", System.currentTimeMillis());
                    map.put("attentionNo", SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.USER_NO, ""));
                    makeOverDetailModel.focusMakeOver(map, statusGZ);
                }
                break;
            case R.id.ll_hanxun://函询
                // 转让 详情函询
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(MakeOverDetailActivity.this);
                } else {
                    if (UserOperating.getInstance().isTeam() || isTeam) {
                        DialogHelper.showSingleDialog(this, "温馨提示", "该功能正在开发中，敬请期待~", "确定", true, new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {

                            }
                        });
                    } else {
                        EnterpriseInquireByLetterActivity.start(this, "1", detailType.equals("商标") ? "2" : detailType.equals("版权") ? "4" :
                                        detailType.equals("专利") ? "3" : detailType.equals("公司") ? "5" : detailType.equals("资产") ? "6" : "",
                                businessId, businessName, dealCompanyName, dealCompanyNo, dealUserName, dealUserNo);

                    }
                }
                break;

            case R.id.tv_gotobug://立即购买
                if (!ClickUtils.isDoubleClick()) {
                    if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                        VerificationCodeLoginActivity.start(MakeOverDetailActivity.this);
                        return;
                    }


                    if (!SharedPreferenceUtil.getInstance().getSaveBooleanData(SharedPreferenceUtil.PERSON_AUTH, false)) {
                        com.sgb.kjwl.utils.DialogHelper.showDialog(getActivity(), "温馨提示", "请先完成实名认证", "去认证", new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {
                                CertificationActivity.start(getActivity(), "1");
                            }
                        });
                        return;
                    }
                    String id = "";
                    int orderType = -1;
                    switch (detailType) {
                        case "商标":
                            orderType = 1;
                            id = makeOverDetailModel.trademarkEntity.getId() + "";
                            break;
                        case "版权":
                            orderType = 3;
                            id = makeOverDetailModel.copyrightEntity.getId() + "";
                            break;
                        case "专利":
                            orderType = 2;
                            id = makeOverDetailModel.patentDetailEntity.getId() + "";
                            break;
                    }
                    makeOverDetailModel.gotocreateorder(orderType, id);
//                CreateBuyMakeOverOrderActivity.startactivity(getActivity(),jsonobject,detailType);
                }
                break;
            case R.id.tv_talkprice://议价
                MToast.showLongToast(getActivity(), "功能开发中，敬请期待！");
                break;
            case R.id.back_view_tool_bar:
                finish();
                break;
            case R.id.back_view_tool_bar_v:
                finish();
                break;
        }

    }


    public void gotobuy() {
        String jsonobject = "";
        switch (detailType) {
            case "商标":
                jsonobject = JSONObject.toJSONString(makeOverDetailModel.trademarkEntity);
                break;
            case "版权":
                jsonobject = JSONObject.toJSONString(makeOverDetailModel.copyrightEntity);
                break;
            case "专利":
                jsonobject = JSONObject.toJSONString(makeOverDetailModel.patentDetailEntity);
                break;
        }
        CreateBuyMakeOverOrderActivity.startactivity(getActivity(), jsonobject, detailType,currentPhone);
    }


    public void setTvIsGz(int isGz) {
        //标是否关注
        if (isGz == 1) {
            statusGZ = 0;
        } else {
            statusGZ = 1;
        }
        updateUserFocusBg();
    }

    private void updateUserFocusBg() {
        //标是否关注
        if (statusGZ == 0) {
            Drawable drawable = getResources().getDrawable(R.mipmap.icon_follow_gray);
            binding.ivFocus.setImageDrawable(drawable);
            binding.tvUserFocus.setText("关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_666666));
        } else {
            Drawable drawable = getResources().getDrawable(R.mipmap.icon_follow_red);
            binding.ivFocus.setImageDrawable(drawable);
            binding.tvUserFocus.setText("已关注");
            binding.tvUserFocus.setTextColor(getResources().getColor(R.color.color_main));
        }
    }

    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    /**
     * 专利
     *
     * @param patent
     */
    @SuppressLint("SetTextI18n")
    public void getPatentEntity(PatentDetailEntity patent) {
        makeOverDetailModel.getPantentRecommendList(String.valueOf(patent.getCategory()), String.valueOf(patent.getId()));
        category = String.valueOf(patent.getCategory());
        businessId = String.valueOf(patent.getId());
        businessName = patent.getName();
        if (patent.getStatus()==0 && patent.getOrderStatus() != 1 && patent.getOrderStatus() != 2 && patent.getOrderStatus() != 4) {
            binding.bidLayout.setVisibility(View.GONE);
            binding.llData.setVisibility(View.GONE);
            binding.llTypeno.setVisibility(View.VISIBLE);
            binding.bidLayout.setAlpha(0.5f);
            binding.bottomView.setClickable(false);
            binding.llReport.setClickable(false);
            binding.llHanxun.setClickable(false);
            binding.llFocus.setClickable(false);
        } else {
            binding.bidLayout.setVisibility(View.VISIBLE);
            binding.llData.setVisibility(View.VISIBLE);
            binding.llTypeno.setVisibility(View.GONE);
            binding.bidLayout.setAlpha(1);
            binding.bottomView.setClickable(true);
            binding.llReport.setClickable(true);
            binding.llHanxun.setClickable(true);
            binding.llFocus.setClickable(true);
        }
        if (patent.getPublishType() == 1) {
            dealCompanyName = patent.getCompanyName();
            dealCompanyNo = patent.getCompanyNo();
        } else if (patent.getPublishType() == 2) {
            dealTeamName = patent.getRealName();
            dealTeamNo = patent.getTeamNo();
        } else {
            dealUserName = patent.getUserRealName();
            dealUserNo = patent.getCreateUser();
        }
        isTeam = patent.getPublishType() == 2;
        currentPhone = patent.getTelPhone();
        man = patent.getContacts();
        List<String> imageList = new ArrayList<>();
        imageList.add(patent.getImg());
        int size = imageList.size();
        if (size == 1) {
            binding.tvPosition.setText(1 + "");
            binding.tvCount.setText(1 + "");
        }

        if (size <= 1) {
            binding.dotLayout.setVisibility(View.GONE);
        }
        if (imageList.size() == 0) {
            imageList.add("");
        }
        categoryPatent = patent.getCategoryName();
        setBannerView(imageList);
        binding.tvTitle.setText(patent.getName());
        switch (patent.getPublishType()) {
            case 0://个人
                binding.tvItemIntelPropPublish.setText("个人");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = patent.getCompanyNo();
                break;
            case 1://企业
                binding.tvItemIntelPropPublish.setText("企业");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = patent.getCompanyNo();
                break;
            case 2://团队
                binding.tvItemIntelPropPublish.setText("团队");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                companyNo = patent.getTeamNo();
                break;
            default:
                binding.tvItemIntelPropPublish.setVisibility(View.GONE);
                break;
        }
        if (patent.getOrderStatus() == 1 || patent.getOrderStatus() == 2 || patent.getOrderStatus() == 4) {
            binding.imageXiajia.setVisibility(View.VISIBLE);
            binding.bidLayout.setVisibility(View.GONE);
        } else {
            binding.imageXiajia.setVisibility(View.GONE);
            binding.bidLayout.setVisibility(patent.getStatus()==0 ? View.GONE : View.VISIBLE);
        }
        binding.tvItemIntelPropHot.setVisibility(patent.getLabel().contains("1") ? View.VISIBLE : View.GONE);
        binding.tvItemIntelPropUrgentSale.setVisibility(patent.getLabel().contains("2") ? View.VISIBLE : View.GONE);
        binding.tvPrice.setText(patent.getPrice() == -1 ? "议价" : TextViewBindingAdapter.setMoneyForRMB("￥" + PointUtils.price(patent.getPrice())));
        binding.tvGotobug.setVisibility(patent.getPrice() == -1 ? View.GONE : View.VISIBLE);
        binding.tvUpdate.setText("更新时间：" + DateUtils.timestampTo13Date3(patent.getUpdateTime()));
        binding.tvMatcheType.setText((patent.getIndustryName()));
        binding.tvBrand.setText((patent.getCategoryName()));
        binding.tvBuyTime.setText((patent.getRegistrationNo()));
        binding.tvWorkTime.setText(((patent.getTalentStatus() == 1 ? "授权未下证" : "授权已下证")));
        binding.tvLine3Left.setText((patent.getApplyTime() == 0 ? "/" : DateUtils.timestampToDate(patent.getApplyTime())));
        binding.tvLine3Right.setText((patent.getExpiresTime() == 0 ? "/" : DateUtils.timestampToDate(patent.getExpiresTime())));
        binding.tvLine4Left.setText((patent.getContacts()));
        binding.tvKey.setText(patent.getExplain() == null || patent.getExplain().equals("") ? "/" : patent.getExplain());

        setImage(patent.getPublishType(), binding.tvEnterpriseRight, patent.getCompanyNo(), patent.getTeamNo(), patent.getUserImg(), patent.getCompanyLogo(), patent.getLogo(), binding.ivLogoPerson, binding.ivLogo
                , patent.getUserRealName(), patent.getCompanyName(), patent.getRealName(), binding.tvEnterpriseName, patent.getCompanyServiceType(), patent.getBusinessType(), binding.tvType, patent.getUserAuthTime()
                , patent.getCompanyAuthTime(), patent.getTeamAuthTime(), binding.tvTimeInto, "个人认证", patent.getUserIsAuth(), "企业认证", patent.getCompanyIsAuth(), "团队认证", patent.getTeamAuth(), binding.tvTypeAuthen, patent.getCreateUser());

        companyNo = patent.getCompanyNo();
        telPhone = patent.getContactNumber();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.lin_question, MakeOverDetailQuestionFragment.newInstance("3"));
        fragmentTransaction.commitAllowingStateLoss();
    }

    private void setBannerView(List<String> imageList) {
        List<CustomViewsInfo> imageListNo = new ArrayList<>();
        if (imageList.size() > 0 && imageList.get(0).equals("")) {
            imageListNo.add(new CustomViewsInfo(R.mipmap.morentu_jingyingbang_detail));
        } else {
            binding.banner.setBackground(getResources().getDrawable(R.color.white));
            for (int i = 0; i < imageList.size(); i++) {
                imageListNo.add(new CustomViewsInfo(imageList.get(i)));
            }
        }
        binding.banner.setBannerData(imageListNo);
        //加载广告图片
        binding.banner.loadImage(new XBanner.XBannerAdapter() {
            @Override
            public void loadBanner(XBanner banner, Object model, View view, int position) {
                if (imageList.size() > 0 && imageList.get(0).equals("")) {
                    if (detailType.equals("专利")) {
                        ((ImageView) view).setScaleType(ImageView.ScaleType.FIT_CENTER);
                        switch (categoryPatent) {
                            case "发明专利":
                                Glide.with(UiUtil.getContext()).load(R.mipmap.qiyefuwu_module_famingzhuanli_for_patent_publish).into((ImageView) view);
                                break;
                            case "实用新型":
                                Glide.with(UiUtil.getContext()).load(R.mipmap.shiyongxinxing_patent_publish).into((ImageView) view);
                                break;
                            case "外观设计":
                                Glide.with(UiUtil.getContext()).load(R.mipmap.waiguansheji_patent_publish).into((ImageView) view);
                                break;
                        }
                    } else {
                        Glide.with(UiUtil.getContext()).load(getResources().getDrawable(R.mipmap.morentu_jingyingbang_detail)).into((ImageView) view);
                    }
                } else {
                    ((ImageView) view).setScaleType(ImageView.ScaleType.FIT_CENTER);
                    Glide.with(UiUtil.getContext()).load(imageList.get(position)).into((ImageView) view);
                }
            }
        });
    }

    /**
     * 版权
     *
     * @param copyright
     */
    @SuppressLint("SetTextI18n")
    public void getCopyrightEntity(CopyrightEntity copyright) {
        makeOverDetailModel.getCopyrightRecommendList(copyright.getCategory(), String.valueOf(copyright.getId()));
        category = copyright.getCategory();
        businessId = String.valueOf(copyright.getId());
        businessName = copyright.getName();
        if (copyright.getStatus() != 1 && copyright.getOrderStatus() != 1 && copyright.getOrderStatus() != 2 && copyright.getOrderStatus() != 4) {
            binding.bidLayout.setVisibility(View.GONE);
            binding.llData.setVisibility(View.GONE);
            binding.llTypeno.setVisibility(View.VISIBLE);
//            binding.bidLayout.setAlpha(0.5f);
            binding.bottomView.setClickable(false);
            binding.llReport.setClickable(false);
            binding.llHanxun.setClickable(false);
            binding.llFocus.setClickable(false);
        } else {
            binding.bidLayout.setVisibility(View.VISIBLE);
            binding.llData.setVisibility(View.VISIBLE);
            binding.llTypeno.setVisibility(View.GONE);
            binding.bidLayout.setAlpha(1);
            binding.bottomView.setClickable(true);
            binding.llReport.setClickable(true);
            binding.llHanxun.setClickable(true);
            binding.llFocus.setClickable(true);
        }
        if (copyright.getPublishType() == 1) {
            dealCompanyName = copyright.getCompanyName();
            dealCompanyNo = copyright.getCompanyNo();
        } else if (copyright.getPublishType() == 2) {
            dealTeamName = copyright.getRealName();
            dealTeamNo = copyright.getTeamNo();
        } else {
            dealUserName = copyright.getUserRealName();
            dealUserNo = copyright.getCreateUser();
        }
        isTeam = copyright.getPublishType() == 2;
        currentPhone = copyright.getTelPhone();
        man = copyright.getContacts();
        List<String> imageList = new ArrayList<>();
        imageList.add(copyright.getImg());
        int size = imageList.size();
        if (size == 1) {
            binding.tvPosition.setText(1 + "");
            binding.tvCount.setText(1 + "");
        }

        if (size <= 1) {
            binding.dotLayout.setVisibility(View.GONE);
        }
        setBannerView(imageList);

        binding.tvTitle.setText(copyright.getName());
        switch (copyright.getPublishType()) {
            case 0://个人
                binding.tvItemIntelPropPublish.setText("个人");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = copyright.getCompanyNo();
                break;
            case 1://企业
                binding.tvItemIntelPropPublish.setText("企业");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = copyright.getCompanyNo();
                break;
            case 2://团队
                binding.tvItemIntelPropPublish.setText("团队");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                companyNo = copyright.getTeamNo();
                break;
            default:
                binding.tvItemIntelPropPublish.setVisibility(View.GONE);
                break;
        }
        if (copyright.getOrderStatus() == 1 || copyright.getOrderStatus() == 2 || copyright.getOrderStatus() == 4) {
            binding.imageXiajia.setVisibility(View.VISIBLE);
            binding.bidLayout.setVisibility(View.GONE);
        } else {
            binding.imageXiajia.setVisibility(View.GONE);

            binding.bidLayout.setVisibility(copyright.getStatus() != 1 ? View.GONE : View.VISIBLE);
        }
        binding.tvItemIntelPropHot.setVisibility(copyright.getLabel().contains("1") ? View.VISIBLE : View.GONE);
        binding.tvItemIntelPropUrgentSale.setVisibility(copyright.getLabel().contains("2") ? View.VISIBLE : View.GONE);
        binding.tvPrice.setText(copyright.getPrice() == -1 ? "议价" : TextViewBindingAdapter.setMoneyForRMB("￥" + PointUtils.price(copyright.getPrice())));
        binding.tvGotobug.setVisibility(copyright.getPrice() == -1 ? View.GONE : View.VISIBLE);
        binding.tvUpdate.setText("更新时间：" + DateUtils.timestampTo13Date3(copyright.getUpdateTime()));
        binding.tvMatcheType.setText((copyright.getCategoryName()));
        binding.tvBrand.setText(((copyright.getAuthorizationMethod() == 1 ? "独家授权" : "非独家授权")));
        binding.tvBuyTime.setText((DateUtils.timestampToDate(copyright.getAuthorizationPeriod())));
        binding.tvWorkTime.setText((copyright.getCopyrightOwner()));
        binding.tvLine3Left.setText((copyright.getRegistrationNo()));
        binding.tvLine3Right.setText((copyright.getAuthor() != null && !copyright.getAuthor().equals("") ? copyright.getAuthor() : "/"));
        binding.tvKey.setText(copyright.getDescription() == null || copyright.getDescription().equals("") ? "/" : copyright.getDescription());

        setImage(copyright.getPublishType(), binding.tvEnterpriseRight, copyright.getCompanyNo(), copyright.getTeamNo(), copyright.getUserImg(), copyright.getCompanyLogo(), copyright.getLogo(), binding.ivLogoPerson, binding.ivLogo
                , copyright.getUserRealName(), copyright.getCompanyName(), copyright.getRealName(), binding.tvEnterpriseName, copyright.getCompanyServiceType(), copyright.getBusinessType(), binding.tvType, copyright.getUserAuthTime()
                , copyright.getCompanyAuthTime(), copyright.getTeamAuthTime(), binding.tvTimeInto, "个人认证", copyright.getUserIsAuth(), "企业认证", copyright.getCompanyIsAuth(), "团队认证", copyright.getTeamAuth(), binding.tvTypeAuthen, copyright.getCreateUser());
        companyNo = copyright.getCompanyNo();
        telPhone = copyright.getContactNumber();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.lin_question, MakeOverDetailQuestionFragment.newInstance("2"));
        fragmentTransaction.commitAllowingStateLoss();
    }

    /**
     * 商标
     *
     * @param trademark
     */
    @SuppressLint("SetTextI18n")
    public void getTrademarkEntity(TrademarkEntity trademark) {
        makeOverDetailModel.getRecommendList(trademark.getCategory(), String.valueOf(trademark.getId()));
        category = trademark.getCategory();
        businessId = String.valueOf(trademark.getId());
        businessName = trademark.getName();
        if (trademark.getStatus() != 1 && trademark.getOrderStatus() != 1 && trademark.getOrderStatus() != 2 && trademark.getOrderStatus() != 4) {
            binding.bidLayout.setVisibility(View.GONE);
            binding.llData.setVisibility(View.GONE);
            binding.llTypeno.setVisibility(View.VISIBLE);
//            binding.bidLayout.setAlpha(0.5f);
            binding.bottomView.setClickable(false);
            binding.llReport.setClickable(false);
            binding.llHanxun.setClickable(false);
            binding.llFocus.setClickable(false);
        } else {
            binding.bidLayout.setVisibility(View.VISIBLE);
            binding.llData.setVisibility(View.VISIBLE);
            binding.llTypeno.setVisibility(View.GONE);
            binding.bidLayout.setAlpha(1);
            binding.bottomView.setClickable(true);
            binding.llReport.setClickable(true);
            binding.llHanxun.setClickable(true);
            binding.llFocus.setClickable(true);
        }
        if (trademark.getPublishType() == 1) {
            dealCompanyName = trademark.getCompanyName();
            dealCompanyNo = trademark.getCompanyNo();
        } else if (trademark.getPublishType() == 2) {
            dealTeamName = trademark.getRealName();
            dealTeamNo = trademark.getTeamNo();
        } else {
            dealUserName = trademark.getUserRealName();
            dealUserNo = trademark.getCreateUser();
        }
        isTeam = trademark.getPublishType() == 2;
        currentPhone = trademark.getTelPhone();
        man = trademark.getContacts();
        List<String> imageList = new ArrayList<>();
        imageList.add(trademark.getImg() != null ? trademark.getImg() : "");
        int size = imageList.size();
        if (size == 1) {
            binding.tvPosition.setText(1 + "");
            binding.tvCount.setText(1 + "");
        }

        if (size <= 1) {
            binding.dotLayout.setVisibility(View.GONE);
        }

        if (trademark.getImg() != null && !trademark.getImg().equals("")) {
            binding.logoViewText.setVisibility(View.GONE);
            binding.banner.setVisibility(View.VISIBLE);
            setBannerView(imageList);
        } else {
            binding.logoViewText.setVisibility(View.VISIBLE);
            binding.banner.setVisibility(View.INVISIBLE);
            if (trademark.getName().length() == 1) {
                binding.logoViewText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
            } else {
                binding.logoViewText.setTextSize(TypedValue.COMPLEX_UNIT_SP, (Math.max((20 - 2 * (trademark.getName().length() / 2)), 10)));
            }
            binding.logoViewText.setTextColor(Color.parseColor("#B79255"));
            binding.logoViewText.setText(TextSizeUtils.singleTextLine(DisplayUtil.dip2px(this, 65), binding.logoViewText.getTextSize(), trademark.getName()));
        }
        if (trademark.getOrderStatus() == 1 || trademark.getOrderStatus() == 2 || trademark.getOrderStatus() == 4) {
            binding.imageXiajia.setVisibility(View.VISIBLE);
            binding.bidLayout.setVisibility(View.GONE);
        } else {
            binding.imageXiajia.setVisibility(View.GONE);
            binding.bidLayout.setVisibility(trademark.getStatus() != 1 ? View.GONE : View.VISIBLE);
        }

        binding.tvTitle.setText(trademark.getName());
        switch (trademark.getPublishType()) {
            case 0://个人
                binding.tvItemIntelPropPublish.setText("个人");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = trademark.getCompanyNo();
                break;
            case 1://企业
                binding.tvItemIntelPropPublish.setText("企业");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = trademark.getCompanyNo();
                break;
            case 2://团队
                binding.tvItemIntelPropPublish.setText("团队");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                companyNo = trademark.getTeamNo();
                break;
            default:
                binding.tvItemIntelPropPublish.setVisibility(View.GONE);
                break;
        }
        binding.tvItemIntelPropHot.setVisibility(trademark.getLabel().contains("1") ? View.VISIBLE : View.GONE);
        binding.tvItemIntelPropUrgentSale.setVisibility(trademark.getLabel().contains("2") ? View.VISIBLE : View.GONE);
        binding.tvPrice.setText(trademark.getPrice() == -1 ? "议价" : TextViewBindingAdapter.setMoneyForRMB("￥" + PointUtils.price(trademark.getPrice())));
        binding.tvGotobug.setVisibility(trademark.getPrice() == -1 ? View.GONE : View.VISIBLE);
        binding.tvUpdate.setText("更新时间：" + DateUtils.timestampTo13Date3(trademark.getUpdateTime()));
        binding.tvMatcheType.setText((trademark.getCategoryName()));
        binding.tvBrand.setText((trademark.getTypeName()));
        binding.tvBuyTime.setText((trademark.getRegistrationNo()));
        binding.tvWorkTime.setText((trademark.getContacts()));
        binding.tvKey.setText(trademark.getRange() == null || trademark.getRange().equals("") ? "/" : trademark.getRange());
        binding.tvKey1.setText(trademark.getExplain() == null || trademark.getExplain().equals("") ? "/" : trademark.getExplain());

        setImage(trademark.getPublishType(), binding.tvEnterpriseRight, trademark.getCompanyNo(), trademark.getTeamNo(), trademark.getUserImg(), trademark.getCompanyLogo(), trademark.getLogo(), binding.ivLogoPerson, binding.ivLogo
                , trademark.getUserRealName(), trademark.getCompanyName(), trademark.getRealName(), binding.tvEnterpriseName, trademark.getCompanyServiceType(), trademark.getBusinessType(), binding.tvType, trademark.getUserAuthTime()
                , trademark.getCompanyAuthTime(), trademark.getTeamAuthTime(), binding.tvTimeInto, "个人认证", trademark.getUserIsAuth(), "企业认证", trademark.getCompanyIsAuth(), "团队认证", trademark.getTeamAuth(), binding.tvTypeAuthen, trademark.getCreateUser());

        companyNo = trademark.getCompanyNo();
        telPhone = trademark.getContactNumber();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.lin_question, MakeOverDetailQuestionFragment.newInstance("1"));
        fragmentTransaction.commitAllowingStateLoss();
    }

    @SuppressLint("SetTextI18n")
    public void getCompanyDetail(CompanyDetailEntity data) {
        makeOverDetailModel.getCompanyRecommendList(data.getIndustryType(), String.valueOf(data.getId()));
        category = data.getIndustryType();
        businessId = String.valueOf(data.getId());
        businessName = data.getTransCompanyName();
        currentPhone = data.getTelPhone();
        if (data.isStatus() != 1) {
            binding.bidLayout.setVisibility(View.GONE);
            binding.llData.setVisibility(View.GONE);
            binding.llTypeno.setVisibility(View.VISIBLE);
//            binding.bidLayout.setAlpha(0.5f);
            binding.bottomView.setClickable(false);
            binding.llReport.setClickable(false);
            binding.llHanxun.setClickable(false);
            binding.llFocus.setClickable(false);
        } else {
            binding.bidLayout.setVisibility(View.VISIBLE);
            binding.llData.setVisibility(View.VISIBLE);
            binding.llTypeno.setVisibility(View.GONE);
            binding.bidLayout.setAlpha(1);
            binding.bottomView.setClickable(true);
            binding.llReport.setClickable(true);
            binding.llHanxun.setClickable(true);
            binding.llFocus.setClickable(true);
        }
        if (data.getPublishType() == 1) {
            dealCompanyName = data.getCompanyName();
            dealCompanyNo = data.getCompanyNo();
        } else if (data.getPublishType() == 2) {
            dealTeamName = data.getRealName();
            dealTeamNo = data.getTeamNo();
        } else {
            dealUserName = data.getUserRealName();
            dealUserNo = data.getCreateUser();
        }
        isTeam = data.getPublishType() == 2;
        man = data.getContact();
        List<String> imageList = new ArrayList<>();
        imageList.add(data.getLogo());
        int size = imageList.size();
        if (size == 1) {
            binding.tvPosition.setText(1 + "");
            binding.tvCount.setText(1 + "");
        }

        if (size <= 1) {
            binding.dotLayout.setVisibility(View.GONE);
        }
        setBannerView(imageList);

        binding.banner.setVisibility(View.GONE);
        binding.rlBottom.setVisibility(View.GONE);
        binding.rlTop.setVisibility(View.GONE);

        binding.tvTitle.setText(data.getTransCompanyName());
        switch (data.getPublishType()) {
            case 0://个人
                binding.tvItemIntelPropPublish.setText("个人");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = data.getCompanyNo();
                break;
            case 1://企业
                binding.tvItemIntelPropPublish.setText("企业");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = data.getCompanyNo();
                break;
            case 2://团队
                binding.tvItemIntelPropPublish.setText("团队");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                companyNo = data.getTeamNo();
                break;
            default:
                binding.tvItemIntelPropPublish.setVisibility(View.GONE);
                break;
        }
        binding.tvItemIntelPropHot.setVisibility(data.getLabel().contains("1") ? View.VISIBLE : View.GONE);
        binding.tvItemIntelPropUrgentSale.setVisibility(data.getLabel().contains("2") ? View.VISIBLE : View.GONE);
        binding.tvPrice.setText(data.getSalePrice() == -1 ? "议价" : TextViewBindingAdapter.setMoneyForRMB("￥" + PointUtils.price(data.getSalePrice())));
        binding.tvUpdate.setText("更新时间：" + DateUtils.timestampTo13Date3(data.getUpdateTime()));

        String companyType;
        switch (data.getEnterpriseType()) {
            case "0":
                companyType = "有限责任公司";
                break;
            case "1":
                companyType = "个人独资公司";
                break;
            case "2":
                companyType = "港澳台公司";
                break;
            default:
                companyType = "集团公司";
                break;
        }

        String taxSale;
        if (data.getTaxScale() == 0) {
            taxSale = "小规模";
        } else if (data.getTaxScale() == 1) {
            taxSale = "一般纳税人";
        } else if (data.getTaxScale() == 2) {
            taxSale = "出口纳税人";
        } else {
            taxSale = "未核税";
        }

        binding.tvMatcheType.setText((data.getSocialCreditCode()));
        binding.tvBrand.setText((companyType));
        binding.tvBuyTime.setText((data.getIndustryName()));
        binding.tvWorkTime.setText((data.getRegisteredCapital() + "万元"));

        String[] tag;
        if (data.getFoundedDate().contains("T")) {
            tag = data.getFoundedDate().split("T");
        } else {
            tag = data.getFoundedDate().split(" ");
        }
        binding.tvLine3Left.setText((tag[0]));
        binding.tvLine3Right.setText((getArea(data.getRegisteredAddr())));
        binding.tvLine4Left.setText(((data.isTaxReturns() ? "正常报税" : "不正常报税")));
        binding.tvLine5Right.setText((taxSale));
        binding.tvKey.setText(data.getOperatingScope() == null || data.getOperatingScope().equals("") ? "/" : data.getOperatingScope());
        binding.tvKey1.setText(data.getOtherInfo() == null || data.getOtherInfo().equals("") ? "/" : data.getOtherInfo());

        setImage(data.getPublishType(), binding.tvEnterpriseRight, data.getCompanyNo(), data.getTeamNo(), data.getUserImg(), data.getCompanyLogo(), data.getLogo(), binding.ivLogoPerson, binding.ivLogo
                , data.getUserRealName(), data.getCompanyName(), data.getRealName(), binding.tvEnterpriseName, data.getCompanyServiceType(), data.getBusinessType(), binding.tvType, data.getUserAuthTime()
                , data.getCompanyAuthTime(), data.getTeamAuthTime(), binding.tvTimeInto, "个人认证", data.getUserIsAuth(), "企业认证", data.getCompanyIsAuth(), "团队认证", data.getTeamAuth(), binding.tvTypeAuthen, data.getCreateUser() + "");

        companyNo = data.getCompanyNo();
        telPhone = data.getPhone();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.lin_question, MakeOverDetailQuestionFragment.newInstance("5"));
        fragmentTransaction.commitAllowingStateLoss();
    }

    private String getArea(String s) {
        RegisterCompanyArea companyArea = new Gson().fromJson(s, RegisterCompanyArea.class);
        return companyArea.getProvinceName() + companyArea.getCityName() + companyArea.getAreaName();
    }

    @SuppressLint("SetTextI18n")
    public void getPropertyDetail(PropertyDetailEntity data) {
        makeOverDetailModel.getPropertyRecommendList(data.getAssetsType(), String.valueOf(data.getId()));
        category = data.getAssetsType();
        businessId = String.valueOf(data.getId());
        businessName = data.getAssetsName();
        if (!data.getStatus().equals("1")) {
            binding.bidLayout.setVisibility(View.GONE);
            binding.llData.setVisibility(View.GONE);
            binding.llTypeno.setVisibility(View.VISIBLE);
            binding.bidLayout.setAlpha(0.5f);
            binding.bottomView.setClickable(false);
            binding.llReport.setClickable(false);
            binding.llHanxun.setClickable(false);
            binding.llFocus.setClickable(false);
        } else {
            binding.bidLayout.setVisibility(View.VISIBLE);
            binding.llData.setVisibility(View.VISIBLE);
            binding.llTypeno.setVisibility(View.GONE);
            binding.bidLayout.setAlpha(1);
            binding.bottomView.setClickable(true);
            binding.llReport.setClickable(true);
            binding.llHanxun.setClickable(true);
            binding.llFocus.setClickable(true);
        }
        if (data.getPublishType() == 1) {
            dealCompanyName = data.getCompanyName();
            dealCompanyNo = data.getCompanyNo();
        } else if (data.getPublishType() == 2) {
            dealTeamName = data.getRealName();
            dealTeamNo = data.getTeamNo();
        } else {
            dealUserName = data.getUserRealName();
            dealUserNo = data.getCreateUser();
        }
        isTeam = data.getPublishType() == 2;
        currentPhone = data.getPhone();
        man = data.getLinkman();
        String[] str1 = data.getCommodityImages().split(",");
        List<String> imageList = new ArrayList<>(Arrays.asList(str1));
        int size = imageList.size();
        if (size == 1) {
            binding.tvPosition.setText(1 + "");
            binding.tvCount.setText(1 + "");
        }

        if (size <= 1) {
            binding.dotLayout.setVisibility(View.GONE);
        }

        setBannerView(imageList);

        binding.tvTitle.setText(data.getAssetsName());
        switch (data.getPublishType()) {
            case 0://个人
                binding.tvItemIntelPropPublish.setText("个人");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = data.getCompanyNo();
                break;
            case 1://企业
                binding.tvItemIntelPropPublish.setText("企业");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                companyNo = data.getCompanyNo();
                break;
            case 2://团队
                binding.tvItemIntelPropPublish.setText("团队");
                binding.tvItemIntelPropPublish.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                binding.tvTypeAuthen.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                companyNo = data.getTeamNo();
                break;
            default:
                binding.tvItemIntelPropPublish.setVisibility(View.GONE);
                break;
        }
        binding.tvItemIntelPropHot.setVisibility(data.getLabel().contains("1") ? View.VISIBLE : View.GONE);
        binding.tvItemIntelPropUrgentSale.setVisibility(data.getLabel().contains("2") ? View.VISIBLE : View.GONE);
        binding.tvPrice.setText(data.getSalePrice() == -1 ? "议价" : TextViewBindingAdapter.setMoneyForRMB("￥" + PointUtils.price(data.getSalePrice())));
        binding.tvUpdate.setText("更新时间：" + DateUtils.timestampTo13Date3(data.getUpdateTime()));

        String[] str = data.getBuyingTime().split("T");
        binding.tvMatcheType.setText((data.getTypeName()));
        binding.tvBrand.setText(((!str[0].equals("") && !str[0].equals("1970-01-01") ? str[0] : "/")));

        String newOrOld;
        switch (data.getAssetsOldNew()) {
            case "1":
                newOrOld = "全新";
                break;
            case "2":
                newOrOld = "95成新";
                break;
            case "3":
                newOrOld = "9成新";
                break;
            case "4":
                newOrOld = "8成新";
                break;
            case "5":
                newOrOld = "7成新及以下";
                break;
            default:
                newOrOld = data.getAssetsOldNew();
                break;
        }

        binding.tvBuyTime.setText(newOrOld.equals("") ? "/" : newOrOld);
        binding.tvWorkTime.setText((((data.getBuyingPrice() > 0 ? PointUtils.price(data.getBuyingPrice()) : "/"))));
        if (data.getDetailedDescription() == null || data.getDetailedDescription().equals("")) {
            binding.tvKey.setVisibility(View.VISIBLE);
            binding.webDescription.setVisibility(View.GONE);
            binding.tvKey.setText("/");
        } else {
            binding.tvKey.setVisibility(View.GONE);
            binding.webDescription.setVisibility(View.VISIBLE);
            binding.webDescription.getSettings().setDefaultTextEncodingName("UTF-8");
            binding.webDescription.getSettings().setJavaScriptEnabled(true);//支持JS
            String js = "<script type=\"text/javascript\">" +
                    "var imgs = document.getElementsByTagName('img');" + // 找到img标签
                    "for(var i = 0; i<imgs.length; i++){" +  // 逐个改变
                    "imgs[i].style.width = '100%';" +  // 宽度改为100%
                    "imgs[i].style.height = 'auto';" +
                    "}" +
                    "</script>";
            binding.webDescription.loadDataWithBaseURL(null, data.getDetailedDescription() + js, "text/html", "UTF-8", null);
        }

        setImage(data.getPublishType(), binding.tvEnterpriseRight, data.getCompanyNo(), data.getTeamNo(), data.getUserImg(), data.getCompanyLogo(), data.getLogo(), binding.ivLogoPerson, binding.ivLogo
                , data.getUserRealName(), data.getCompanyName(), data.getRealName(), binding.tvEnterpriseName, data.getCompanyServiceType(), data.getBusinessType(), binding.tvType, data.getUserAuthTime()
                , data.getCompanyAuthTime(), data.getTeamAuthTime(), binding.tvTimeInto, "个人认证", data.getUserIsAuth(), "企业认证", data.getCompanyIsAuth(), "团队认证", data.getTeamAuth(), binding.tvTypeAuthen, data.getCreateUser() + "");

        companyNo = data.getCompanyNo();
        telPhone = data.getContactNumber();

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.lin_question, MakeOverDetailQuestionFragment.newInstance("4"));
        fragmentTransaction.commitAllowingStateLoss();
    }

    @Override
    protected void onResume() {
        super.onResume();
        getDetail();
    }

    @SuppressLint("SetTextI18n")
    public void setImage(int publishType, ImageView imageArrow, String companyId, String teamNo
            , String urlPerson, String urlCompany, String urlTeam, ImageView imageViewPerson, ImageView imageViewCompany
            , String namePerson, String nameCompany, String nameTeam, TextView nameTextView
            , String businessTypeCompany, String businessTypeTeam, TextView businessTypeTextView
            , long authTimePerson, long authTimeCompany, long authTimeTeam, TextView authTimeTextView
            , String authStatusPerson, int personAuth, String authStatusCompany, int companyAuth, String authStatusTeam, int teamAuth, TextView authStatusTextView, String userId) {
        String url, name, businessType, authTime, authStatus;
        RequestOptions optionsP;
        ImageView imageView;
        if (publishType == 0) {
            optionsP = personOptions;
            url = urlPerson;
            imageArrow.setVisibility(View.GONE);
            name = namePerson;
            businessTypeTextView.setVisibility(View.INVISIBLE);
            businessType = "";
            authTime = DateUtils.timestampToDate(0);
            authStatus = authStatusPerson;
            if (personAuth == 1) {
                authStatusTextView.setVisibility(View.VISIBLE);
            } else {
                authStatusTextView.setVisibility(View.GONE);
            }
            imageView = imageViewPerson;
            imageViewCompany.setVisibility(View.GONE);
            imageViewPerson.setVisibility(View.VISIBLE);
            mId = "个人";
            mTag = userId;
        } else if (publishType == 1) {
            optionsP = options;
            url = urlCompany;
            imageArrow.setVisibility(View.VISIBLE);
            businessTypeTextView.setVisibility(View.VISIBLE);
            name = nameCompany;
            businessType = "经营类型:" + businessTypeCompany;
            authTime = DateUtils.timestampToDate(authTimeCompany);
            authStatus = authStatusCompany;
            if (companyAuth == 1) {
                authStatusTextView.setVisibility(View.VISIBLE);
            } else {
                authStatusTextView.setVisibility(View.GONE);
            }
            imageView = imageViewCompany;
            imageViewCompany.setVisibility(View.VISIBLE);
            imageViewPerson.setVisibility(View.GONE);
            mTag = companyId;
            mId = "企业";
            if (name != null && !name.equals("")) {
                imageArrow.setVisibility(View.VISIBLE);
            } else {
                imageArrow.setVisibility(View.GONE);
            }
        } else {
            optionsP = teamOptions;
            url = urlTeam;
            imageArrow.setVisibility(View.GONE);
            businessTypeTextView.setVisibility(View.VISIBLE);
            name = nameTeam;
            businessType = "经营类型:" + businessTypeTeam;
            authTime = DateUtils.timestampToDate(authTimeTeam);
            authStatus = authStatusTeam;
            if (teamAuth == 2) {
                authStatusTextView.setVisibility(View.VISIBLE);
            } else {
                authStatusTextView.setVisibility(View.GONE);
            }
            imageView = imageViewPerson;
            imageViewCompany.setVisibility(View.GONE);
            imageViewPerson.setVisibility(View.VISIBLE);
            mTag = teamNo;
            mId = "团队";
            authTimeTextView.setVisibility(View.GONE);
            if (name != null && !name.equals("")) {
                imageArrow.setVisibility(View.VISIBLE);
            } else {
                imageArrow.setVisibility(View.GONE);
            }
        }

        Glide.with(this).load(url).apply(optionsP).into(imageView);
        nameTextView.setText(name);
        businessTypeTextView.setText(businessType.equals("经营类型:null") ? "" : businessType);
        authTimeTextView.setText(authTime + "入驻");
        authStatusTextView.setText(authStatus);
        if (authTime.equals("1970-01-01")) {
            authTimeTextView.setVisibility(View.GONE);
        }
    }

    //展示商标推荐数据
    public void showRecommend(List list) {
        if (list != null && list.size() > 0) {
            binding.flRecommendList.setVisibility(View.VISIBLE);
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fl_recommend_list, RecommendForYouFragment.newInstance("商标", "", category, list));
            transaction.commitAllowingStateLoss();
        } else {
            binding.flRecommendList.setVisibility(View.GONE);
        }
    }

    //展示版权推荐数据
    public void showCopyrightRecommend(List list) {
        if (list != null && list.size() > 0) {
            binding.flRecommendList.setVisibility(View.VISIBLE);
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fl_recommend_list, RecommendForYouFragment.newInstance("版权", "", category, list));
            transaction.commitAllowingStateLoss();
        } else {
            binding.flRecommendList.setVisibility(View.GONE);
        }
    }

    //展示专利推荐数据
    public void showPatentRecommend(List list) {
        if (list != null && list.size() > 0) {
            binding.flRecommendList.setVisibility(View.VISIBLE);
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fl_recommend_list, RecommendForYouFragment.newInstance("专利", "", category, list));
            transaction.commitAllowingStateLoss();
        } else {
            binding.flRecommendList.setVisibility(View.GONE);
        }
    }

    //展示公司推荐数据
    public void showCompanyRecommend(List list) {
        if (list != null && list.size() > 0) {
            binding.flRecommendList.setVisibility(View.VISIBLE);
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fl_recommend_list, RecommendForYouFragment.newInstance("公司", "", category, list));
            transaction.commitAllowingStateLoss();
        } else {
            binding.flRecommendList.setVisibility(View.GONE);
        }
    }

    //展示资产推荐数据
    public void showPropertyRecommend(List list) {
        if (list != null && list.size() > 0) {
            binding.flRecommendList.setVisibility(View.VISIBLE);
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.add(R.id.fl_recommend_list, RecommendForYouFragment.newInstance("资产", "", category, list));
            transaction.commitAllowingStateLoss();
        } else {
            binding.flRecommendList.setVisibility(View.GONE);
        }
    }
}
